package com.example.hanfu_bk.mapper;

import org.apache.ibatis.annotations.*;
import com.example.hanfu_bk.pojo.Style;

import java.util.List;

@Mapper
public interface StyleMapper {

    @Select("select * from style")
    List<Style> searchAll();

    @Select("select * from style "+
            "where name=#{name} and type_id = #{typeId}")
    List<Style> searchCate(String name, Integer typeId);

    @Select("select * from style "+
            "where name=#{name}")
    List<Style> searchCateByName(String name);

    @Select("select * from style "+
            "where type_id = #{typeId}")
    List<Style> searchCateByType(Integer typeId);

    @Delete("delete from style where id = #{id}")
    void deleteCate(Integer id);

    @Insert("insert into style(type_id,name,description,image_url) values (#{typeId},#{name},#{description},#{imageUrl})")
    void addCate(Style style);

    @Update("UPDATE style SET " +
            "type_id = #{typeId}, " +
            "name = #{name}, " +
            "description = #{description}, " +
            "image_url = #{imageUrl} " +
            "WHERE id = #{id}")
    void updateCate( Style style);


}
